// 路由配置文件
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '',
    redirect: () => {
      return {
        path: '/mall/home'
      }
    }
  },
  {
    path: '/community',
    name: 'community',
    component: () => import('@/views/community/Community.vue'),
    redirect: () => {
      return {
        path: '/community/home'
      }
    },
    children: [
      {
        path: 'home',
        name: 'community-home',
        component: () => import('@/views/community/CommunityHome.vue')
      },
      {
        path: 'test',
        name: 'community-test',
        component: () => import('@/views/community/CommunityTest.vue')
      }
    ]
  },
  {
    path: '/mall',
    name: 'mall',
    component: () => import('@/views/mall/Mall.vue'),
    redirect: () => {
      return {
        path: '/mall/home'
      }
    },
    children: [
      {
        path: 'home',
        name: 'mall-home',
        component: () => import('@/views/mall/MallHome.vue')
      },
      {
        path: 'product/detail/:id',
        name: 'product-detail',
        props: true,
        component: () => import('@/views/mall/ProductDetail.vue')
      }
    ]
  },
  {
    path: '/chat',
    name: 'chat',
    component: () => import('@/views/chat/Chat.vue')
  },
  {
    path: '/detection',
    name: 'detection',
    component: () => import('@/views/TestPage.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
